<?php
require_once('Debug.class.php');
class SQL
{
	var $sql_query;
	var $conn;
    var $query;
    var $tabla;

	function Query($sql)
    {
    	$this->sql_query = $sql;

    	$this->query = @mysql_query($this->sql_query, $this->conn);
        $error     = @mysql_error($this->conn);
        if (!empty($error))
        {
            Debug::Mostrar("Se ha producido un error en una consulta a la Base de Datos - Error 1: Cargar()<br>".$this->sql_query."<br>".$error);
        }
    }
	function Crear_Query($Tabla, $Campos, $Where = "")
    {
    	$this->tabla = $Tabla;

		$select = '';
        foreach ($Campos as $i => $campos)
        {
			$select .= $campos;
            if ($i < (count($Campos)-1))
            {
           		$select .= ', ';
            }
        }
        $sql = 'SELECT '.$select.' FROM '.$this->tabla;
        if (!empty($Where))
        {
        	$sql .= ' WHERE '.$Where;
        }

        $this->Query($sql);
    }
    function Fetch()
    {
    	if ($row = @mysql_fetch_object($this->query))
        {
            return $row;
        }
        return 0;
    }
}
?>